<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>营业厅订单管理</title>
		<!-- Tell the browser to be responsive to screen width -->
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!-- Font Awesome -->
		<link rel="stylesheet" href="../../plugins/font-awesome/css/font-awesome.min.css">
		<!-- Ionicons -->
		<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
		<!-- Theme style -->
		<link rel="stylesheet" href="../../dist/css/adminlte.min.css">
		<!-- iCheck -->
		<link rel="stylesheet" href="../../plugins/iCheck/flat/blue.css">
		<!-- Morris chart -->
		<link rel="stylesheet" href="../../plugins/morris/morris.css">
		<!-- jvectormap -->
		<link rel="stylesheet" href="../../plugins/jvectormap/jquery-jvectormap-1.2.2.css">
		<!-- Date Picker -->
		<link rel="stylesheet" href="../../plugins/datepicker/datepicker3.css">
		<!-- Daterange picker -->
		<link rel="stylesheet" href="../../plugins/daterangepicker/daterangepicker-bs3.css">
		<!-- bootstrap wysihtml5 - text editor -->
		<link rel="stylesheet" href="../../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
		<!-- Google Font: Source Sans Pro -->
		<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
		<!-- DataTables -->
		<link rel="stylesheet" href="../../plugins/datatables/dataTables.bootstrap4.css">
	</head>

	<body class="hold-transition sidebar-mini">
		<section class="content">
			<div class="row">
				<div class="col-12">
					<div class="card">
						<div class="card-header">
							<h3 class="card-title"><b>营业厅订单管理</b></h3>
						</div>
						<!-- /.card-header -->
						<div class="card-body">
							<table id="example2" class="table table-bordered table-hover">
								<thead>
									<tr>
										<th>货物出发地</th>
										<th>装车单号</th>
										<th>汽运编号</th>
										<th>目的地</th>
										<th>出发日期</th>
										<th>车辆代号</th>
										<th>运费</th>
										<th>监装员</th>
										<th>押运员</th>

									</tr>
								</thead>
								<tbody id="windows" >

								</tbody>
								<tfoot>
									<tr>
										<th>货物出发地</th>
										<th>装车单号</th>
										<th>汽运编号</th>
										<th>目的地</th>
										<th>出发日期</th>
										<th>车辆代号</th>
										<th>运费</th>
										<th>监装员</th>
										<th>押运员</th>
									</tr>
								</tfoot>
							</table>
						</div>
						<!-- /.card-body -->
					</div>
					<!-- /.card -->
					<!-- /.card -->
				</div>
				<!-- /.col -->
			</div>
			<!-- /.row -->
		</section>
		<!-- /.content -->

		<!-- jQuery -->
		<script src="../../plugins/jquery/jquery.min.js"></script>
		<!-- jQuery UI 1.11.4 -->
		<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
		<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
		<script>
			$.widget.bridge('uibutton', $.ui.button)
		</script>
		<!-- Bootstrap 4 -->
		<script src="../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
		<!-- DataTables -->
		<link rel="stylesheet" href="../../plugins/datatables/dataTables.bootstrap4.css">
		<!-- Theme style -->
		<link rel="stylesheet" href="../../dist/css/adminlte.min.css">
		<!-- Morris.js charts -->
		<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
		<script src="../../plugins/morris/morris.min.js"></script>
		<!-- Sparkline -->
		<script src="../../plugins/sparkline/jquery.sparkline.min.js"></script>
		<!-- jvectormap -->
		<script src="../../plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
		<script src="../../plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
		<!-- jQuery Knob Chart -->
		<script src="../../plugins/knob/jquery.knob.js"></script>
		<!-- daterangepicker -->
		<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script>
		<script src="../../plugins/daterangepicker/daterangepicker.js"></script>
		<!-- datepicker -->
		<script src="../../plugins/datepicker/bootstrap-datepicker.js"></script>
		<!-- Bootstrap WYSIHTML5 -->
		<script src="../../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
		<!-- Slimscroll -->
		<script src="../../plugins/slimScroll/jquery.slimscroll.min.js"></script>
		<!-- FastClick -->
		<script src="../../plugins/fastclick/fastclick.js"></script>
		<!-- AdminLTE App -->
		<script src="../../dist/js/adminlte.js"></script>
		<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
		<script src="../../dist/js/pages/dashboard.js"></script>
		<!-- AdminLTE for demo purposes -->
		<script src="../../dist/js/demo.js"></script>
		<script src="../../js/jquery.cookie.js"></script>
		<!-- page script -->
		<script>
			$(function() {
				$("#example1").DataTable();
				$('#example2').DataTable({
					"paging": true,
					"lengthChange": false,
					"searching": false,
					"ordering": true,
					"info": true,
					"autoWidth": false
				});
			});
		</script>
		<script>
			var hloading=[];
			$.ajax({
				type: "post", //请求方式
				async: true, //是否异步
				xhrFields:{withCredentials:true},
				crossDomain:true,
				url: "http://localhost:8073/show_hloading",
				dataType: "json", //跨域json请求一定是jsonp
				// jsonp: "callback", //跨域请求的参数名，默认是callback
				//jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串
				data:{sid:$.cookie("sid")}, //请求参数
				beforeSend: function() {
					//请求前的处理
					//alert("请求前")
				},
				success: function(data) {
					//alert("反馈值")
					$.each(data, function(i, d) {
						
						$("#windows").append("<tr>" +
							" <td>"+d.hid.hname+"</td>" +
							" <td>OR9842"+d.hlid+"</td>" +
							" <td>"+d.trucksnumber+"</td>" +
							" <td>"+d.tid.tname+"</td>" +
							"  <td>"+d.truckdate+"</td>" +
							" <td>"+d.cid.licenseplate+"</td>" +
							" <td>"+d.carriage+"</td>" +
							" <td>"+d.inspectionofstorage.name+"</td>"+
							"<td>"+d.zone.name+"</td>" +
							"</tr>");
							$("#windows").append("<tr><td colspan='9'><div class='card'>" +
							"<div class='card-header border-transparent'>" +
							"<h4>货物信息</h4>"+
							"<div class='card-tools'>" +
							"<button type='button' class='btn btn-tool' data-widget='collapse'>" +
							" <i class='fa fa-minus'></i>" +
							"</button>" +
							"</div>" +
							"</div>" +
							" <div class='card-body p-0'>" +
							"<div class='table-responsive'>" +
							"<table class='table m-0'>" +
							" <thead>" +
							"<tr>" +
							"<th>货物ID</th>" +
							"<th>出发日期</th>" +
							"<th>是否被签收</th>" +
							"<th>货物目的地</th>" +
							"</tr>" +
							"</thead>" +
							"<tbody id='OR984"+d.hlid+"'>" +
							
							" </tbody>" +
							"</table>" +
							"</div>" +
							"</div>" +
							"<div class='card-footer clearfix'>" +
							"<select id='goodsState"+d.hlid+"' class='form-control' style='width: 150px;'>" +
                	        "<option value='正常'>正常</option>" +
                	        "<option value='损坏'>损坏</option>" +
                	        "<option value='部分损坏'>部分损坏</option>" +
                            "</select>" +
                            "<br/>" +
							"<a href='javascript:void(0)' class='btn btn-sm btn-info float-left'  onclick='Reviewiscompleted("+i+")'>审核完毕</a>" +
							"</div>" +
							"</div></td></tr>");
							select_Commodity_Hloading(d.hlid)
						    hloading[i]=d;
					});
					//请求成功处理，和本地回调完全一样

				},
				complete: function(data) {
					//请求完成的处理
					//alert(data)
					// alert("请求完成")
				},
				error: function() {
					window.location.replace("500.html");
				}

			});

			//查找货物信息
			function select_Commodity_Hloading(hlid) {
				$.ajax({
					type: "post", //请求方式
					async: true, //是否异步
					xhrFields:{withCredentials:true},
					crossDomain:true,
					url: "http://localhost:8073/select_Commodity_Hloading",
					dataType: "json", //跨域json请求一定是jsonp
					// jsonp: "callback", //跨域请求的参数名，默认是callback
					//jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串
					data: {
						"query": hlid
					}, //请求参数
					beforeSend: function() {
						//请求前的处理
						//alert("请求前")
					},
					success: function(data) {
						$.each(data, function(i, d) {
							$("#OR984"+hlid+"").append(" <tr>" +
							"<td><a href='#' onclick='getSasid("+d.sasid+")'>OR9842"+d.sasid+"</a></td>" +
							"<td>"+d.starting+"</td>" +
							"<td><span class='badge badge-success'>"+d.issignforit+"</span></td>" +
							" <td>" +
							" <div class='sparkbar' data-color='#00a65a' data-height='20'>"+d.cargoinformation+"</div>" +
							"</td>" +
							"</tr>");
						});
						//请求成功处理，和本地回调完全一样

					},
					complete: function(data) {
						//请求完成的处理
						//alert(data)
						// alert("请求完成")
					},
					error: function() {
						window.location.replace("500.html");
					}

				});
			};
			/*调用父窗口内的函数*/
			function getSasid(sasid){
				window.parent.showMyCart(sasid);
			}
			//审核完毕                    出发营业厅 出发中转站 中转单号 装车单号
			function Reviewiscompleted(hlid){
				//alert(hloading[hlid].hid.hname)
				//alert($("#goodsState"+hloading[hlid].hlid+"").val())//货物状态
				$.ajax({
					type: "post", //请求方式
					async: true, //是否异步
					xhrFields:{withCredentials:true},
					crossDomain:true,
					url: "http://localhost:8073/Reviewiscompleted",
					dataType: "json", //跨域json请求一定是jsonp
					// jsonp: "callback", //跨域请求的参数名，默认是callback
					//jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串
					data: {hid:hloading[hlid].hid.hid,hlid:hloading[hlid].hlid,goodsState:$("#goodsState"+hloading[hlid].hlid+"").val(),sid:$.cookie("sid")}, //请求参数
					beforeSend: function() {
						//请求前的处理
						//alert("请求前")
					},
					success: function(data) {
                    window.location.reload();
					},
					complete: function(data) {
						window.parent.dataFilling();//调用父窗口函数
						//请求完成的处理
						//alert(data)
						// alert("请求完成")
					},
					error: function() {
						window.location.replace("500.html");
					}

				});
			}
		</script>
	</body>

</html>